﻿using System;
using System.Linq.Expressions;
using Wisdom.Core;

namespace Wisdom.Core.Repositories
{
    /// <summary>
    /// 聚合根排序参数
    /// </summary>
    /// <typeparam name="TAggregateRoot">聚合根.</typeparam>
    public class OrderByParameter<TAggregateRoot>
        where TAggregateRoot : class, IAggregateRoot
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="keySelector">排序表达式.</param>
        /// <param name="sortOrder">排序方式.</param>
        public OrderByParameter(Expression<Func<TAggregateRoot, dynamic>> keySelector, SortOrder sortOrder)
        {
            this.KeySelector = keySelector;
            this.SortOrder = sortOrder;
        }
        /// <summary>
        /// 排序表达式.
        /// </summary>
        public Expression<Func<TAggregateRoot, dynamic>> KeySelector { get; set; }
        /// <summary>
        /// 排序方式.
        /// </summary>
        public SortOrder SortOrder { get; set; }
    }
}